{% extends "base.html" %}

{% block header%}
<title>开分支 编辑</title>
{% endblock %}

{% block content %}
{% with model_name='Task' url_prefix='/pack/task/task?task_type=1' %}
<div class="bar">
	<a>开分支 管理</a> -> 开分支 配置编辑
	<div class="buttons">
		<a  class="btn btn-app btn-grey btn-xs radius-4 pull-right submit"  />保存</a>
	</div>
</div>

<form action="{{url_prefix}}" method="post">
	<table class="form2">
    <tr>
		<th>项目：</th>
        <td>
            <select id="proj_tag_select" name="proj_tag">
                {% for p in project_objs %}
                    <option value="{{p.pro_tag}}">{{p.pro_name}}</option>
                {% endfor %}
            </select>
        </td>
	</tr>
    <tr>
        <th>基于分支：</th>
        <td>
            <select id="prev_branch_name_select" name="prev_branch_name">
                    <option value="">无</option>
                {% for p in prev_bra_objs %}
                    <option value="{{p.branch_name}}">{{p.branch_name}}</option>
                {% endfor %}
            </select>
        </td>
	</tr>
	<tr>
		<th>新分支：</th>
        <td>
            <input type="text" name="branch_name" required="required"/>
        </td>
	</tr>
</table>
</form>
<script>
    var pro_bra_dict = {{ pro_bra_dic | safe }}
    $(function(){
        var pre_branch_select = $("#prev_branch_name_select");
        var proj_tag_select = $("#proj_tag_select");
        proj_tag_select.change(function () {
            pre_branch_select[0].options.length=0;
            pre_branch_select.append("<option value=''>无</option>");
            var bra_options = pro_bra_dict[$("#proj_tag_select").val()];
            for(var i in bra_options){
                pre_branch_select.append("<option value='" + bra_options[i] + "'>" + bra_options[i] + "</option>");
            }
        });
        proj_tag_select.change()
    })
</script>
{% endwith %}
{% endblock %}